Repository navigation
feat(objectql, spec): a number or boolean comparand on a text- or option-family field compares as its stored string - #33518
Conversation
…ion-family field compares as its stored string Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
… option fields Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
… bigint probe prints Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
…-stored comparand exports Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
…, and the conformance census classifies it Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
📓 Docs Drift Check17 anchor(s) derived from 2 changed package(s); no hand-written page names any of them. What this run could not see
Coarse fallback — 174 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 488a786c69db1677bd9d536a70c1a30f417dacd6 && git checkout 488a786c69db1677bd9d536a70c1a30f417dacd6
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 811b976aa3faf138db0ec1cc9bd17dca6329b94c 63e03db212bc998337bfd788e55370291995916a && git checkout -B drift-repro 811b976aa3faf138db0ec1cc9bd17dca6329b94c && git merge --no-ff 63e03db212bc998337bfd788e55370291995916a
node scripts/docs-audit/affected-docs.mjs --json 811b976aa3faf138db0ec1cc9bd17dca6329b94c |
|
Contract-review-claim: session_016WV4cxDxAYxdtDhtR1kQQe · head b67f2b8 · 2026-11-14T23:25:39Z |
Contract reviewServed-tier: review#2 (server area pilot) · area A4 · Fixes #29486 (p1, maintainer ruling A) · published-spec face. CI on this head at review time: Check Changeset green, 12 success, 9 skipped, 24 in progress, none failing. ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentThe equality and list half holds against the cited code and the card's scenario, on all six drivers. One gap must be fixed before landing:
Implemented-by: VERDICT: FAIL One should-fix (S1), which is a declaration plus one cross-driver case under option (a). The delta comes back to review#2. |
…field is a string range Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
|
Contract-review-claim: session_016WV4cxDxAYxdtDhtR1kQQe · head 63e03db · 2026-11-14T23:42:32Z |
Contract reviewServed-tier: review#2 (server area pilot) · area A4 · Fixes #29486 (p1, maintainer ruling A) · delta on my FAIL at ① Derived judgments
② Semver levelUnchanged from the first round: ③ Boundary flagsUnchanged: not security sensitive, no cross-area file, and legacy rows stay with #29643. ④ Design judgment
Implemented-by: VERDICT: PASS Final round. Land once CI is green on this head (the six driver conformance suites run the new cases). |
|
domain:server#5 · os-elon-musk · session_016WV4cw787kMeaX7oyz7DDC CI note · head 63e03db · 2026-11-15T00:06Z
Step taken (platform-readings ①): re-run the failed job once via |
|
domain:server#5 · os-elon-musk · session_016WV4cw787kMeaX7oyz7DDC ACCEPT · area A4 · head 63e03db · 2026-11-15T00:28Z
|
Requested by Elon · project thread
Fixes #29486
Clause-②: yes (widening) — a filter that compares a text-family or option-family field with a number or a boolean now matches the rows the write door stored for that value (
String(value)); before, it matched none on every driver, with no error.Metadata-protocol: semantic
Skills-docs:
content/docs/deployment/cli.mdx(os migrate text-scalars,os migrate option-codes) now says a filter on the number reads as the string; noskills/**page teaches how a filter reads a comparand on a text or option field.维护者速读
42→"42",true→"true"),与写入时存储的形式一致。42存成"42",但过滤{ code: 42 }在所有驱动上都静默返回空列表、不报错;按维护者裁决 A 统一为字符串比较。$gt/$between等)在这类字段上变为字符串比较({ code: { $gt: 9 } }不匹配"10"),已在 changeset 中声明;唯一变窄的是未迁移的旧数据(driver-memory 持久化里的原始数字42以前能被{ code: 42 }匹配,现在不能,需跑os migrate text-scalars/option-codes,migrate(value-shapes): option fields keep old raw number/boolean and SQLite "N.0" rows after #29562; scan and rewrite to the declared code #29643 跟踪)。回滚即回退本 PR。packages/objectql/src/number-comparand-declared-type-door.ts(walk 里新增的第三个 arm,风险 hunk 在walkCondition的 else 分支与declaredFactsOf);packages/spec/src/data/filter-string-stored-comparand-declared-type.ts(判定函数与字段族);packages/spec/src/data/filter-comparand-type-conformance.ts(跨驱动用例表)。pnpm --filter @objectstack/rest exec vitest run src/rest-data-option-scalar-value.test.ts,预期全部通过,其中{ stage: 3 }返回写入为3和"3"的两行。What changes
@objectstack/spec/data— newfilter-string-stored-comparand-declared-type.ts: the judged families are the write side's three sets by identity (BOUNDED_STRING_FIELD_TYPES,SINGLE_OPTION_TYPES,MULTI_OPTION_TYPES), the positions are the number door's operator lists by identity ($eq $ne $gt $gte $lt $lte, members of$in $nin $between), and the pure verdictstringStoredComparandDoorVerdictnarrows a number or boolean toString(value)(a bigint within ±2^53 as the number it names) and passes everything else. It never refuses.nullstays the null test.@objectstack/objectql— a third arm of the one field-aware filter walk (number-comparand-declared-type-door.ts), asked where neither the number nor the boolean arm judges (the classes are disjoint). Every engine site that already runs the walk inherits it:whereon both spellings for find / findOne / count / aggregate / update / delete, the per-aggregationfilter,having, andjudgeFilter. No driver-local change.$gt/$gte/$lt/$ltebound and each$betweenmember is narrowed like any comparand, so a range on a text or option field compares strings in the column's order:{ code: { $gt: 9 } }does not match"10"("10"<"9"as strings), and{ code: { $between: [1, 10] } }does not match"5". Before, InMemoryDriver and MongoDB matched no row for a number bound (they do not order a number against a string), and SQLite compared by column affinity: measured on a text column holding"10","5","42","alpha",{ $gt: 9 }matched"alpha",{ $between: [1, 10] }matched"10", and{ $gt: 4, $lt: 5 }matched"5"and"42", where it now matches"42"alone. Declared in the changeset's "What answers differently" and in the spec module header's measured table; pinned by three range cases in the cross-driver table (single-digit bounds, which every collation orders the same way).FILTER_STRING_STORED_COMPARAND_CASESinfilter-comparand-type-conformance.ts: each case carries the filter as written and the filter the engine door hands every driver, plus the ids it matches overFILTER_STRING_STORED_COMPARAND_ROWS. Classified inscripts/check-driver-conformance.mjs'sCASE_SETS; every driver runs it (memory, sql matrix, mongodb server-free, sqlite-wasm, turso local, odata through the real engine).packages/rest/src/rest-data-option-scalar-value.test.ts:{ stage: 3 }FROM no row TO both rows written3/"3", plustrue, mixed$in,$ne, and thePOST …/querydoor.content/docs/deployment/cli.mdx: the two migrate sections say a filter on the number now reads as the string, so it also misses unmigrated rows.@objectstack/specminor,@objectstack/objectqlpatch.Tests
Premise, measured before any edit (base-equivalent built tree, InMemoryDriver and SQLite through engine.insert / engine.find)
Measured on a built tree at
8fd19455f, whosepackages/objectql/src,packages/spec/src/data,packages/drivers/driver-sql/srcandpackages/drivers/driver-memory/srcdiffer from base9499dcc53only inrecycle-bin/restore*:Suites at the merged head (after `git merge origin/main`)
pnpm --filter @objectstack/objectql test— Test Files 595 passed (595), Tests 13005 passed (13005)pnpm --filter @objectstack/spec test— Test Files 841 passed (841), Tests 26877 passed, 1 todomemory-comparand-type-conformance.test.ts36 passed; driver-sqlsql-driver-comparand-type-conformance.test.ts58 passed, 2 skipped (unprovisioned live cells); driver-mongodbmongodb-comparand-type-conformance.test.ts33 passedrest-data-option-scalar-value.test.ts+rest-data-text-scalar-value.test.ts— 19 passedodata-driver.conformance.test.ts718 passedRound 2 (review#2 S1), head `63e03db212`: the range cases, every touched suite
filter-string-stored-comparand-declared-type.test.ts12 passed; objectqlengine-boolean-comparand-declared-type-door.test.ts43 passedpnpm check:driver-conformanceexit 0 (OK — 72 covered cell(s), 6 in the DEBT ledger, 0 exempt);node scripts/check-changeset-no-major.mjs --base origin/mainexit 0 (nomajor; the level axis reads the PR body in CI)Ablation (one-time, not kept)
node scripts/ablation-replace.mjsreplaced the arm'sjudged = judgeFieldSpec(stringStoredArm(stringMeta), key, value, here);withcontinue;(anchor 1 → 0, blobacdfa13031d8→e4c81394a2b4).engine-boolean-comparand-declared-type-door.test.ts: Tests 7 failed | 36 passed (43). Restored: blob == HEAD (acdfa13031d8),git diff HEADempty. The test imports the engine fromsrc/, so nodist/leg applies.Acceptance notes
multiselect,checkboxes,tags, amultiple: trueselect): the arm narrows a scalar comparand there too, as the write side reads each element, but both measured drivers refuse any scalar comparison against such a field (INVALID_FILTER, "use$contains") before and after, so nothing observable moves. Kept as the drivers answer it; no new semantics.options(an object registered in code, as the write door's own pins do) or from a row written before the rule: a declared code is a system identifier, so"3"is never one and the write door refuses3on a select that declares its codes."true"/"false"are legal codes anywhere. The table's select fixture declares none for that reason; its spec test pins thatFieldSchemarefuses it.42on driver-memory with persistence,"42.0"on SQLite) are not migrated here, per the ruling (migrate(value-shapes): option fields keep old raw number/boolean and SQLite "N.0" rows after #29562; scan and rewrite to the declared code #29643). A raw42matched{ code: 42 }before and no longer does.Metadata-protocol: semantic, not the claim'snone: the ruling sets spec at minor, andcheck-changeset-no-major.mjs's level axis grades a declarednonepatch-only; a filter a view or flow already stores changes meaning, which is thesemanticrow.check:skill-examples,check:dual-build-cjs-loads,check:type-check-debt. CI runs them.Verification
b67f2b81f6. Local derived gate families (node scripts/pm/dispatch-gates.mjs --commands): 106 exit 0;check:driver-conformancered on its first run (the new case set unclassified), then fixed in this PR and re-run:OK — 72 covered cell(s), 6 in the DEBT ledger, 0 exempt. The families derived from the gate-script edit are run separately (see the report comment).63e03db212— the touched suites,check:driver-conformance,check:changeset-no-major,check:spec-docblock-symbol-anchors,check:nul-bytes,check:issue-citationsandcheck:doc-authoring, all exit 0.Generated by Claude Code
🤖 Generated with Claude Code
https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC